package com.lyz.myself.config.enums;

import java.util.HashMap;
import java.util.Map;

public enum Flag {
    no("1", "否"), yes("2", "是"), other("0", "其它");

    private static Map<String, Flag> valueMap = new HashMap<>();

    static {
        for (Flag e : Flag.values()) {
            valueMap.put(e.code, e);
        }
    }

    private String code;
    private String name;

    private Flag(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static Flag valueOfCode(String code) {
        Flag result = valueMap.get(code);
        if (result == null) {
            throw new IllegalArgumentException("未知的枚举类型：" + code + ",请核对枚举 Flag");
        }
        return result;
    }

}